package com.adb.droid;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.adb.droid.ui.FeedScreenActivity;
import com.adb.droid.ui.MapInputActivity;
import com.adb.droid.ui.ProductDetailsActivity;

/**
 * Launcher activity for list of activity name 
 * @author bhavdip
 *
 */
public class ChooseActivity extends ListActivity{
	
	private static final String TAG = ChooseActivity.class.getCanonicalName();
	
	private ListView mActivityScreensList;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.d(TAG,"onCreate");

		/** array of activity name **/
		String[] activityArray = new String[] { "Product Details activity",
				"Feed Screen", "Map input snapshot", "Photo selection" };
		mActivityScreensList = getListView();
		mActivityScreensList.setPadding(30,30,30,30);
		setListAdapter(new ArrayAdapter<String>(getApplicationContext(),
				R.layout.row_choose_item_list, R.id.lbl_screen_name,
				activityArray));
		mActivityScreensList.setOnItemClickListener(mlistItemClickListener);
	}
	
	@Override
	protected void onStart() {
		super.onStart();
		Log.d(TAG,"onStart");
	}
	
	@Override
	protected void onStop() {
		super.onStop();
		Log.d(TAG,"onStop");
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		Log.d(TAG,"onResume");
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		Log.d(TAG,"onDestroy");
	}
	
	/**
	 * Activity Item click listener 
	 */
	private OnItemClickListener mlistItemClickListener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int itemPosition,
				long arg3) {
//			Toast.makeText(getApplicationContext(),
//					"Item Click" + itemPosition, Toast.LENGTH_LONG).show();
			if (itemPosition == 0) {
				startActivity(new Intent(getApplicationContext(),
						ProductDetailsActivity.class));
			} else if (itemPosition == 1) {
				startActivity(new Intent(getApplicationContext(),
						FeedScreenActivity.class));
			} else if (itemPosition == 2) {
				startActivity(new Intent(getApplicationContext(),
						MapInputActivity.class));
			} else if (itemPosition == 3) {

			}
		}
	};
	
}
